﻿@page "/plugin/{id}"
@inherits BaseComponent

<PageTitle>@model?.Name - @AppConfig.AppTitle</PageTitle>

<div class="container cl-container cl-plugin">
    <CmsCard>
        <HeadTemplate>
            <CmsTitle Icon="far fa-file" Title="插件详情" />
            <UPluginCount Plugin="model" />
        </HeadTemplate>
        <ChildContent>
            <div class="title">
                <h1>@model?.Name</h1>
                <div class="tags">
                    <AntTag Color="blue">@model?.Category</AntTag>
                    @if (model?.Type == "免费")
                    {
                        <AntTag Color="green">免费</AntTag>
                    }
                    else
                    {
                        <AntTag Color="blue">@model?.Price</AntTag>
                    }
                </div>
            </div>
            <blockquote>@model?.Summary</blockquote>
            <div class="content">
                @CmsUtils.GetMarkdownHtml(model?.Description)
            </div>
            <div class="button">
                <AntButton Name="返回" Type="default" OnClick="location='./plugin';" />
            </div>
        </ChildContent>
    </CmsCard>
</div>

@code {
    private IPluginService Service;
    private CmPlugin model;

    protected override async Task OnInitAsync()
    {
        await base.OnInitAsync();
        Service = await CreateServiceAsync<IPluginService>();
        model = await Service.GetPluginAsync(Id);
    }
}